# encoding=utf8
import sys
reload(sys)
sys.setdefaultencoding('utf8')
from ..MessageAnalysis import*

class JT_8100:
    result = []
    str=""
    analysisDescription = ['应答流水号:', '结果:']
    #字段长度，以字节为单位
    analysis8100Length=[2,1]
    def LogicAisle(self, protocolStr, header):
        print "header0001=%s"%header[1].split(':')[1]
        count = 0
        for i in range(len(self.analysisDescription)):
            if i==1:
                str=protocolStr[count:count + (self.analysis8100Length[i] * 2)]
                print(str)
                if str=="00":
                    header.append(self.analysisDescription[1] + str +"成功"+ "\n")
                    print (protocolStr[count+(self.analysis8100Length[i] * 2):-4])
                    header.append("鉴权码:"+protocolStr[count+(self.analysis8100Length[i] * 2):-4]+"\n")
                elif str=="01":
                    header.append(self.analysisDescription[1] + str + "车辆已被注册" + "\n")
                elif str=="02":
                    header.append(self.analysisDescription[1] + str + "数据库中无该车辆" + "\n")
                elif str=="03":
                    header.append(self.analysisDescription[1] + str + "终端已被注册" + "\n")
                elif str=="04":
                    header.append(self.analysisDescription[1] + str + "数据库中无该终端" + "\n")
                count = count + self.analysis8100Length[i] * 2
            elif i==0:
                header.append(self.analysisDescription[i] + protocolStr[count:count + (self.analysis8100Length[i] * 2)] + "\n");
                count = count + self.analysis8100Length[i] * 2
        self.result = header
